<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			uni.addInterceptor('request', {
				invoke(args) {
					if (!args.url.startsWith("http")) {
					    args.url = 'http://192.168.1.68:8080' + args.url;
					};
				},
			});
			
			if (uni.getSystemInfoSync().platform === 'android') {
			        plus.android.requestPermissions(
			            ['android.permission.WRITE_EXTERNAL_STORAGE', 'android.permission.READ_EXTERNAL_STORAGE'],
			            function(granted) {
			                console.log("存储权限已授权");
			            },
			            function(denied) {
			                console.error("存储权限被拒绝");
			                uni.showToast({
			                    title: "请手动开启存储权限",
			                    icon: "none"
			                });
			            }
			        );
			    }
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		// #ifdef APP-ANDROID
		onLastPageBackPress: function () {
			console.log('App LastPageBackPress')
			if (firstBackTime == 0) {
				uni.showToast({
					title: '再按一次退出应用',
					position: 'bottom',
				})
				firstBackTime = Date.now()
				setTimeout(() => {
					firstBackTime = 0
				}, 2000)
			} else if (Date.now() - firstBackTime < 2000) {
				firstBackTime = Date.now()
				uni.exit()
			}
		},
		// #endif
		onExit: function () {
			console.log('App Exit')
		},
	}
</script>

<style>
	/*每个页面公共css */
</style>
